package cn.org.donald.framework.config;

/**
 * @author ： Donald
 * @date ： 2020/10/20 18:55
 * @description： 拦截返回数据进行封装
 *//*
@EnableWebMvc
@Configuration*/
public class ResponseConfig {

    /*@RestControllerAdvice
    static class ResponseAdvice implements ResponseBodyAdvice<Object>{


        @Override
        public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
            return true;
        }

        @Override
        public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
            if (body instanceof BaseResult){
                return body;
            }
            if (body instanceof String){
                HttpResult objectHttpResult = new HttpResult(body);
                return JSON.toJSONString(objectHttpResult);
            }

            if (body instanceof Throwable){
                return body;
            }

            if (body instanceof LinkedHashMap){
                return body;
            }

            HttpResult objectHttpResult = new HttpResult(body);
            return objectHttpResult;
        }
    }*/
}
